<!--  -->
<template>
  <div class="table">
    <!-- 新增按钮 
    <el-button type="success" plain @click="dialogTableVisible = true"
      >新增 add</el-button><hr>-->

    <el-form
      :inline="true"
      :model="dataForm"
      @keyup.enter.native="getDataList()"
    >
      <el-form-item>
        <el-input
          v-model="dataForm.key"
          placeholder="用户名／用户操作"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :data="
        tableData.filter(
          (data) =>
            !search ||
            data.operation.toLowerCase().includes(search.toLowerCase())
        )
      "
      stripe
      height="500"
      border
      style="width: 100%"
    >
      <el-table-column fixed type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="操作时间">
              <span>{{ props.row.createAt }}</span>
            </el-form-item>
            <el-form-item label="操作内容">
              <span>{{ props.row.operation }}</span>
            </el-form-item>
            <el-form-item label="执行时间">
              <span>{{ props.row.time }}</span>
            </el-form-item>
            <el-form-item label="ip地址">
              <span>{{ props.row.ip }}</span>
            </el-form-item>
            <el-form-item label="用户名">
              <span>{{ props.row.username }}</span>
            </el-form-item>
            <el-form-item label="调用方法">
              <span>{{ props.row.method }}</span>
            </el-form-item>
            <el-form-item label="参数传递">
              <span>{{ props.row.params }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column fixed prop="createAt" header-align="center"
        align="center" label="操作时间" width="230">
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        prop="operation"
        label="操作内容"
        width="200"
      >
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        prop="time"
        label="执行时间（毫秒）"
        width="150"
      >
      </el-table-column>
      <el-table-column prop="ip" header-align="center"
        align="center" label="ip地址" width="120"> </el-table-column>
      <el-table-column prop="username" header-align="center"
        align="center" label="用户名" width="120">
      </el-table-column>
      <el-table-column prop="method" header-align="center"
        align="center" label="调用方法" width="350">
      </el-table-column>
      <el-table-column prop="params" header-align="center"
        align="center" label="参数传递" width="500">
      </el-table-column>
    </el-table>

    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="33"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
  </div>
</template>

<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #0d57be;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      dataForm: {
        key: "",
      },
      tableData: [],
      search: "",
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      selectionDataList: [],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    getTableData() {
      this.$http({
        url: this.$http.adornUrl("/monitormanage/sys/log/list"),
        method: "get",
      }).then(({ data }) => {
        console.log(data.page.list);
        console.log(data, "查看传参类型");
        this.tableData = data.page.list;
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {
    this.getTableData();
  }, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
</style>